#ifndef __PROC_REQ_H__
#define __PROC_REQ_H__

//#include "../../2_DLL/DLL/RAD_CONF.h"

#ifdef _WIN64
#define MAX_WIDTH           1440
#define MAX_HEIGHT          2992
#elif _WIN32
#define MAX_WIDTH           2496
#define MAX_HEIGHT          2992
#endif


// we allocate the maximum flash size for all cases.
#define MAX_FLASH_SIZE_QHD  32 * 1024 * 1024 / 8    // 32 MB
#define MAX_FLASH_SIZE_128M  128 * 1024 * 1024 / 8 // 12B MB

// the size of demura configuration file, here we define 256 bytes
#define DEMURA_CFG_SIZE     8192     // demura config size

// Initial code size
#define INITIAL_CODE_SIZE 1024
#define MAX_INIT_CODE_SIZE 8192

#define MAX_FLASH_AMOUNT 8
#define MAX_INIT_CODE_AMOUNT MAX_FLASH_AMOUNT

/* definition of return type */
enum
{
	RTN_TYPE_BMP = 0,
	RTN_TYPE_FLASH,
};

struct DataBufMS
{
	double* pdDstBufPtr0M_R;
	double* pdDstBufPtr1M_R;
	double* pdDstBufPtr2M_R;
	double* pdDstBufPtr3M_R;
	double* pdDstBufPtr4M_R;
	double* pdDstBufPtr0S_R;
	double* pdDstBufPtr1S_R;
	double* pdDstBufPtr2S_R;
	double* pdDstBufPtr3S_R;
	double* pdDstBufPtr4S_R;
	double* pdDstBufPtr0M_G;
	double* pdDstBufPtr1M_G;
	double* pdDstBufPtr2M_G;
	double* pdDstBufPtr3M_G;
	double* pdDstBufPtr4M_G;
	double* pdDstBufPtr0S_G;
	double* pdDstBufPtr1S_G;
	double* pdDstBufPtr2S_G;
	double* pdDstBufPtr3S_G;
	double* pdDstBufPtr4S_G;
	double* pdDstBufPtr0M_B;
	double* pdDstBufPtr1M_B;
	double* pdDstBufPtr2M_B;
	double* pdDstBufPtr3M_B;
	double* pdDstBufPtr4M_B;
	double* pdDstBufPtr0S_B;
	double* pdDstBufPtr1S_B;
	double* pdDstBufPtr2S_B;
	double* pdDstBufPtr3S_B;
	double* pdDstBufPtr4S_B;

	char* pdProcBufPtr0M_R;
	char* pdProcBufPtr1M_R;
	char* pdProcBufPtr2M_R;
	char* pdProcBufPtr3M_R;
	char* pdProcBufPtr4M_R;
	char* pdProcBufPtr0S_R;
	char* pdProcBufPtr1S_R;
	char* pdProcBufPtr2S_R;
	char* pdProcBufPtr3S_R;
	char* pdProcBufPtr4S_R;
	char* pdProcBufPtr0M_G;
	char* pdProcBufPtr1M_G;
	char* pdProcBufPtr2M_G;
	char* pdProcBufPtr3M_G;
	char* pdProcBufPtr4M_G;
	char* pdProcBufPtr0S_G;
	char* pdProcBufPtr1S_G;
	char* pdProcBufPtr2S_G;
	char* pdProcBufPtr3S_G;
	char* pdProcBufPtr4S_G;
	char* pdProcBufPtr0M_B;
	char* pdProcBufPtr1M_B;
	char* pdProcBufPtr2M_B;
	char* pdProcBufPtr3M_B;
	char* pdProcBufPtr4M_B;
	char* pdProcBufPtr0S_B;
	char* pdProcBufPtr1S_B;
	char* pdProcBufPtr2S_B;
	char* pdProcBufPtr3S_B;
	char* pdProcBufPtr4S_B;
	//   unsigned char   pucBuf0[MAX_WIDTH * MAX_HEIGHT];
};

struct ColorDataSrc
{
	double pd000_R[MAX_WIDTH * MAX_HEIGHT];     // input source data for demura processing
	double pd000_G[MAX_WIDTH * MAX_HEIGHT];
	double pd000_B[MAX_WIDTH * MAX_HEIGHT];

	double pd016_R[MAX_WIDTH * MAX_HEIGHT];
	double pd016_G[MAX_WIDTH * MAX_HEIGHT];
	double pd016_B[MAX_WIDTH * MAX_HEIGHT];

	double pd032_R[MAX_WIDTH * MAX_HEIGHT];
	double pd032_G[MAX_WIDTH * MAX_HEIGHT];
	double pd032_B[MAX_WIDTH * MAX_HEIGHT];

	double pd064_R[MAX_WIDTH * MAX_HEIGHT];
	double pd064_G[MAX_WIDTH * MAX_HEIGHT];
	double pd064_B[MAX_WIDTH * MAX_HEIGHT];

	double pd096_R[MAX_WIDTH * MAX_HEIGHT];
	double pd096_G[MAX_WIDTH * MAX_HEIGHT];
	double pd096_B[MAX_WIDTH * MAX_HEIGHT];

	double pd128_R[MAX_WIDTH * MAX_HEIGHT];
	double pd128_G[MAX_WIDTH * MAX_HEIGHT];
	double pd128_B[MAX_WIDTH * MAX_HEIGHT];

	double pd160_R[MAX_WIDTH * MAX_HEIGHT];
	double pd160_G[MAX_WIDTH * MAX_HEIGHT];
	double pd160_B[MAX_WIDTH * MAX_HEIGHT];

	double pd192_R[MAX_WIDTH * MAX_HEIGHT];
	double pd192_G[MAX_WIDTH * MAX_HEIGHT];
	double pd192_B[MAX_WIDTH * MAX_HEIGHT];

	double pd224_R[MAX_WIDTH * MAX_HEIGHT];
	double pd224_G[MAX_WIDTH * MAX_HEIGHT];
	double pd224_B[MAX_WIDTH * MAX_HEIGHT];

	unsigned char   pucBmpSrc[MAX_WIDTH * MAX_HEIGHT * 3];  // BMP data Source
	unsigned char   pucDllCtrl[DEMURA_CFG_SIZE];            // demura dll control configuration data
	unsigned char   ucQueryType;                            // demura control query type, 0: demura process, 1: judgment
	unsigned char   reserve[7];

	double	mask_R[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R2[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G2[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B2[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R3[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G3[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B3[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R4[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G4[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B4[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R5[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G5[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B5[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R6[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G6[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B6[MAX_WIDTH * MAX_HEIGHT];

	double	mask_R7[MAX_WIDTH * MAX_HEIGHT];
	double	mask_G7[MAX_WIDTH * MAX_HEIGHT];
	double	mask_B7[MAX_WIDTH * MAX_HEIGHT];
};

struct DemuraIn
{
	double* pd000_R;     // input source data for demura processing
	double* pd000_G;
	double* pd000_B;

	double* pd016_R;
	double* pd016_G;
	double* pd016_B;

	double* pd032_R;
	double* pd032_G;
	double* pd032_B;

	double* pd064_R;
	double* pd064_G;
	double* pd064_B;

	double* pd096_R;
	double* pd096_G;
	double* pd096_B;

	double* pd128_R;
	double* pd128_G;
	double* pd128_B;

	double* pd160_R;
	double* pd160_G;
	double* pd160_B;

	double* pd192_R;
	double* pd192_G;
	double* pd192_B;

	double* pd224_R;
	double* pd224_G;
	double* pd224_B;

	unsigned char* pucBmpSrc;

	unsigned char* pucDllCtrl;

	double* mask_R;
	double* mask_G;
	double* mask_B;

	double* mask_R2;
	double* mask_G2;
	double* mask_B2;

	double* mask_R3;
	double* mask_G3;
	double* mask_B3;

	double* mask_R4;
	double* mask_G4;
	double* mask_B4;

	double* mask_R5;
	double* mask_G5;
	double* mask_B5;

	double* mask_R6;
	double* mask_G6;
	double* mask_B6;

	double* mask_R7;
	double* mask_G7;
	double* mask_B7;
};

/* for temp. processing */
struct DataBuf
{
	double pdBuf0_R[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf1_R[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf2_R[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf3_R[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf4_R[MAX_WIDTH * MAX_HEIGHT];

	double pdBuf0_G[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf1_G[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf2_G[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf3_G[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf4_G[MAX_WIDTH * MAX_HEIGHT];

	double pdBuf0_B[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf1_B[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf2_B[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf3_B[MAX_WIDTH * MAX_HEIGHT];
	double pdBuf4_B[MAX_WIDTH * MAX_HEIGHT];

	double pdBuf9[MAX_WIDTH * MAX_HEIGHT]; // temp buffer for processing in prediction and combination.

	char pdProcBuf0_R[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf1_R[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf2_R[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf3_R[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf4_R[MAX_WIDTH * MAX_HEIGHT];

	char pdProcBuf0_G[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf1_G[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf2_G[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf3_G[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf4_G[MAX_WIDTH * MAX_HEIGHT];

	char pdProcBuf0_B[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf1_B[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf2_B[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf3_B[MAX_WIDTH * MAX_HEIGHT];
	char pdProcBuf4_B[MAX_WIDTH * MAX_HEIGHT];

	char pdProcBuf9[MAX_WIDTH * MAX_HEIGHT];

	DataBufMS DataBufMS;

};

struct DataBufEx {
	double* pdBuf0_R;
	double* pdBuf1_R;
	double* pdBuf2_R;
	double* pdBuf3_R;
	double* pdBuf4_R;

	double* pdBuf0_G;
	double* pdBuf1_G;
	double* pdBuf2_G;
	double* pdBuf3_G;
	double* pdBuf4_G;

	double* pdBuf0_B;
	double* pdBuf1_B;
	double* pdBuf2_B;
	double* pdBuf3_B;
	double* pdBuf4_B;

	double* pdBuf9; // temp buffer for processing in prediction and combination.

	char* pdProcBuf0_R;
	char* pdProcBuf1_R;
	char* pdProcBuf2_R;
	char* pdProcBuf3_R;
	char* pdProcBuf4_R;

	char* pdProcBuf0_G;
	char* pdProcBuf1_G;
	char* pdProcBuf2_G;
	char* pdProcBuf3_G;
	char* pdProcBuf4_G;

	char* pdProcBuf0_B;
	char* pdProcBuf1_B;
	char* pdProcBuf2_B;
	char* pdProcBuf3_B;
	char* pdProcBuf4_B;

	char* pdProcBuf9;

	DataBufMS DataBufMS;
};

// compensated data result
struct CompDataResult
{
	unsigned char pucCompData[MAX_WIDTH * MAX_HEIGHT * 3 + 1];      // compensated data in gray level with BMP file header 54 bytes
	unsigned char pucFlhCompData[MAX_FLASH_SIZE_QHD + 1];           // compensated data for flash
	unsigned char pucFlhCompData2[MAX_FLASH_SIZE_QHD + 1];           // compensated data for flash
	unsigned char pucFlhCompData3[MAX_FLASH_SIZE_QHD + 1];           // compensated data for flash
	unsigned char pucFlhCompData4[MAX_FLASH_SIZE_QHD + 1];           // compensated data for flash
	unsigned char ucJudgmentResult;                             // judgment result
	unsigned char reserve[7];
	unsigned char initial_code[INITIAL_CODE_SIZE];
	int initial_code_page_20_len;
	int initial_code_page_22_len;
	int iTotalFlash;
};

struct DemuraOut
{
	int iTotalFlash;
	int iCompDataSize[8];
	unsigned char pucFlhCompData[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData2[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData3[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData4[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData5[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData6[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData7[MAX_FLASH_SIZE_128M];
	unsigned char pucFlhCompData8[MAX_FLASH_SIZE_128M];

	int iTotalInitCode;
	int initial_code_size[8];
	unsigned char initial_code[MAX_INIT_CODE_SIZE];
	unsigned char initial_code2[MAX_INIT_CODE_SIZE];
	unsigned char initial_code3[MAX_INIT_CODE_SIZE];
	unsigned char initial_code4[MAX_INIT_CODE_SIZE];
	unsigned char initial_code5[MAX_INIT_CODE_SIZE];
	unsigned char initial_code6[MAX_INIT_CODE_SIZE];
	unsigned char initial_code7[MAX_INIT_CODE_SIZE];
	unsigned char initial_code8[MAX_INIT_CODE_SIZE];
	int initial_code_page_20_len;
	int initial_code_page_22_len;

	unsigned char* pucCompData;

	int initial_code_page_F4_len;
	int initial_code_page_F6_len;
};

#endif